<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/html/axios.min.js"></script>
    <script src="/html/util.js"></script>
    <script>
        //得到从前一页面提交的表单数据
        var id = getQuery("id");
        window.onload  = function (){
            showInfo();
        }

        function showInfo(){
            axios.get("/car/findById",{
                params:{
                    id
                }
            }).then(e => {
               var info = e.data;
               $("type").innerHTML = info.type;
               $("price").value = info.price;
               $("color").innerHTML = info.color;
            });
        }

        function update(){
            axios.get("/car/update",{
                params:{
                    id,
                    price:$("price").value
                }
            }).then(e => {
                var info = e.data;
                if(info == "ok"){
                    location.href = "/html/car/index.html";
                }
            });
        }
    </script>
</head>
<body>
    <h2>修改汽车信息</h2>
    品牌：<span id="type"></span><br>
    价格：<input type="text" id="price"><br>
    颜色：<span id="color"></span><br>
    <input type="button" value="修改" onclick="update()">
</body>
</html>